/*
 * ControlGastoView.java
 */

package controlgasto;

import ar.lucas.controlgasto.altas.AltaGasto;
import ar.lucas.controlgasto.altas.AltaPersona;
import ar.lucas.controlgasto.comparar.CompararMes;
import ar.lucas.controlgasto.config.Propiedades;
import ar.lucas.controlgasto.dao.PersonaDAO;
import ar.lucas.controlgasto.modificaciones.ModificarGasto;
import ar.lucas.controlgasto.modificaciones.ModificarPersona;
import ar.lucas.controlgasto.statgraphs.drawGraphsPanel;
import ar.lucas.controlgasto.utils.ReloadCombo;
import ar.lucas.controlgasto.utils.TableUtils;
import java.io.IOException;
import org.jdesktop.application.Action;
import org.jdesktop.application.SingleFrameApplication;
import org.jdesktop.application.FrameView;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JDialog;
import javax.swing.JFrame;

/**
 * The application's main frame.
 */
public class ControlGastoView extends FrameView {

    boolean fromDialogClosed = false;

    public ControlGastoView(SingleFrameApplication app) {
        super(app);
        Propiedades.initGeneralProper();
        initComponents();
//        if(selecciondb == null){
//            JFrame mainFrame = ControlGastoApp.getApplication().getMainFrame();
//            selecciondb = new SelectDB(mainFrame, true);
//            selecciondb.setLocationRelativeTo(mainFrame);
//        }
//        ControlGastoApp.getApplication().show(selecciondb);
//        JFrame mainFrame = ControlGastoApp.getApplication().getMainFrame();
//        selecciondb = new SelectDB(mainFrame, true);
//        selecciondb.setLocationRelativeTo(null);
//        selecciondb.setVisible(true);
    }

    @Action
    public void showAboutBox() {
        if (aboutBox == null) {
            JFrame mainFrame = ControlGastoApp.getApplication().getMainFrame();
            aboutBox = new ControlGastoAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        ControlGastoApp.getApplication().show(aboutBox);
    }

    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        tabs_graficos = new javax.swing.JTabbedPane();
        panel_opciones = new javax.swing.JPanel();
        opciones_calendario = new com.toedter.calendar.JCalendar();
        comboPersonas = new javax.swing.JComboBox();
        label_mayor_gasto = new javax.swing.JLabel();
        txt_mayor_gasto = new javax.swing.JTextField();
        label_total_anio1 = new javax.swing.JLabel();
        label_total_mes = new javax.swing.JLabel();
        txt_total_mes = new javax.swing.JTextField();
        label_total_anio = new javax.swing.JLabel();
        txt_total_anio = new javax.swing.JTextField();
        txt_descripcion = new javax.swing.JTextField();
        label_mayor_gasto1 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        panel_informacion = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tabla_informacion = new javax.swing.JTable(){
            public boolean isCellEditable(int rowIndex, int vColIndex) {
                return false;
            }};
            menuBar = new javax.swing.JMenuBar();
            javax.swing.JMenu fileMenu = new javax.swing.JMenu();
            jMenu1 = new javax.swing.JMenu();
            jMenuItem1 = new javax.swing.JMenuItem();
            jMenuItem3 = new javax.swing.JMenuItem();
            jMenu2 = new javax.swing.JMenu();
            jMenuItem4 = new javax.swing.JMenuItem();
            jMenuItem5 = new javax.swing.JMenuItem();
            javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
            jMenu3 = new javax.swing.JMenu();
            jMenuItem2 = new javax.swing.JMenuItem();
            javax.swing.JMenu helpMenu = new javax.swing.JMenu();
            javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
            jScrollPane1 = new javax.swing.JScrollPane();
            jTable1 = new javax.swing.JTable();

            mainPanel.setName("mainPanel"); // NOI18N

            org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(controlgasto.ControlGastoApp.class).getContext().getResourceMap(ControlGastoView.class);
            tabs_graficos.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("tabs_graficos.border.title"))); // NOI18N
            tabs_graficos.setName("tabs_graficos"); // NOI18N

            panel_opciones.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("panel_opciones.border.title"))); // NOI18N
            panel_opciones.setName("panel_opciones"); // NOI18N

            opciones_calendario.setBorder(javax.swing.BorderFactory.createEtchedBorder());
            opciones_calendario.setName("opciones_calendario"); // NOI18N
            opciones_calendario.addMouseListener(new java.awt.event.MouseAdapter() {
                public void mouseClicked(java.awt.event.MouseEvent evt) {
                    opciones_calendarioMouseClicked(evt);
                }
            });

            comboPersonas.setName("comboPersonas"); // NOI18N
            comboPersonas.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    comboPersonasActionPerformed(evt);
                }
            });

            label_mayor_gasto.setText(resourceMap.getString("label_mayor_gasto.text")); // NOI18N
            label_mayor_gasto.setName("label_mayor_gasto"); // NOI18N

            txt_mayor_gasto.setEditable(false);
            txt_mayor_gasto.setHorizontalAlignment(javax.swing.JTextField.CENTER);
            txt_mayor_gasto.setText(resourceMap.getString("txt_mayor_gasto.text")); // NOI18N
            txt_mayor_gasto.setName("txt_mayor_gasto"); // NOI18N

            label_total_anio1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
            label_total_anio1.setText(resourceMap.getString("label_total_anio1.text")); // NOI18N
            label_total_anio1.setName("label_total_anio1"); // NOI18N

            label_total_mes.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
            label_total_mes.setText(resourceMap.getString("label_total_mes.text")); // NOI18N
            label_total_mes.setName("label_total_mes"); // NOI18N

            txt_total_mes.setEditable(false);
            txt_total_mes.setHorizontalAlignment(javax.swing.JTextField.CENTER);
            txt_total_mes.setName("txt_total_mes"); // NOI18N

            label_total_anio.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
            label_total_anio.setText(resourceMap.getString("label_total_anio.text")); // NOI18N
            label_total_anio.setName("label_total_anio"); // NOI18N

            txt_total_anio.setEditable(false);
            txt_total_anio.setHorizontalAlignment(javax.swing.JTextField.CENTER);
            txt_total_anio.setName("txt_total_anio"); // NOI18N

            txt_descripcion.setEditable(false);
            txt_descripcion.setName("txt_descripcion"); // NOI18N

            label_mayor_gasto1.setText(resourceMap.getString("label_mayor_gasto1.text")); // NOI18N
            label_mayor_gasto1.setName("label_mayor_gasto1"); // NOI18N

            jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
            jButton1.setName("jButton1"); // NOI18N
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
                }
            });

            javax.swing.GroupLayout panel_opcionesLayout = new javax.swing.GroupLayout(panel_opciones);
            panel_opciones.setLayout(panel_opcionesLayout);
            panel_opcionesLayout.setHorizontalGroup(
                panel_opcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(opciones_calendario, javax.swing.GroupLayout.DEFAULT_SIZE, 240, Short.MAX_VALUE)
                .addGroup(panel_opcionesLayout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(label_total_anio1, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(txt_descripcion, javax.swing.GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE)
                    .addContainerGap())
                .addGroup(panel_opcionesLayout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(panel_opcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(panel_opcionesLayout.createSequentialGroup()
                            .addComponent(label_total_mes, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(txt_total_mes, javax.swing.GroupLayout.DEFAULT_SIZE, 89, Short.MAX_VALUE))
                        .addGroup(panel_opcionesLayout.createSequentialGroup()
                            .addComponent(label_total_anio, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(txt_total_anio, javax.swing.GroupLayout.DEFAULT_SIZE, 89, Short.MAX_VALUE)))
                    .addGap(72, 72, 72))
                .addGroup(panel_opcionesLayout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(panel_opcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(label_mayor_gasto)
                        .addComponent(label_mayor_gasto1))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(panel_opcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(panel_opcionesLayout.createSequentialGroup()
                            .addComponent(comboPersonas, 0, 151, Short.MAX_VALUE)
                            .addContainerGap())
                        .addGroup(panel_opcionesLayout.createSequentialGroup()
                            .addComponent(txt_mayor_gasto, javax.swing.GroupLayout.DEFAULT_SIZE, 89, Short.MAX_VALUE)
                            .addGap(72, 72, 72))))
                .addGroup(panel_opcionesLayout.createSequentialGroup()
                    .addGap(51, 51, 51)
                    .addComponent(jButton1)
                    .addContainerGap(64, Short.MAX_VALUE))
            );
            panel_opcionesLayout.setVerticalGroup(
                panel_opcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panel_opcionesLayout.createSequentialGroup()
                    .addComponent(opciones_calendario, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(panel_opcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(comboPersonas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(label_mayor_gasto1))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(panel_opcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(txt_mayor_gasto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(label_mayor_gasto))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(panel_opcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(txt_descripcion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(label_total_anio1))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(panel_opcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(txt_total_mes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(label_total_mes))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(panel_opcionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(txt_total_anio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(label_total_anio))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 24, Short.MAX_VALUE)
                    .addComponent(jButton1)
                    .addContainerGap())
            );

            ReloadCombo.llenarComboPersonas(comboPersonas);

            panel_informacion.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("panel_informacion.border.title"))); // NOI18N
            panel_informacion.setMaximumSize(new java.awt.Dimension(494, 337));
            panel_informacion.setName("panel_informacion"); // NOI18N

            jScrollPane2.setName("jScrollPane2"); // NOI18N

            tabla_informacion.setName("tabla_informacion"); // NOI18N
            TableUtils.buscarGastosMesActual(tabla_informacion,opciones_calendario.getMonthChooser().getMonth()+1);
            jScrollPane2.setViewportView(tabla_informacion);

            javax.swing.GroupLayout panel_informacionLayout = new javax.swing.GroupLayout(panel_informacion);
            panel_informacion.setLayout(panel_informacionLayout);
            panel_informacionLayout.setHorizontalGroup(
                panel_informacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 573, Short.MAX_VALUE)
            );
            panel_informacionLayout.setVerticalGroup(
                panel_informacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 302, Short.MAX_VALUE)
            );

            javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
            mainPanel.setLayout(mainPanelLayout);
            mainPanelLayout.setHorizontalGroup(
                mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(mainPanelLayout.createSequentialGroup()
                    .addComponent(panel_informacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(panel_opciones, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addComponent(tabs_graficos, javax.swing.GroupLayout.DEFAULT_SIZE, 843, Short.MAX_VALUE)
            );
            mainPanelLayout.setVerticalGroup(
                mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
                    .addComponent(tabs_graficos, javax.swing.GroupLayout.DEFAULT_SIZE, 252, Short.MAX_VALUE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(panel_informacion, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(panel_opciones, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
            );

            /*try{
                tabs_graficos.add("Mensual",new drawGraphsPanel().genLineGraph(opciones_calendario.getDate()));
            }
            catch (SQLException ex) {
                Logger.getLogger(TableUtils.class.getName()).log(Level.SEVERE, null, ex);
            }*/

            menuBar.setName("menuBar"); // NOI18N

            fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N

            jMenu1.setText(resourceMap.getString("jMenu1.text")); // NOI18N
            jMenu1.setName("jMenu1"); // NOI18N

            jMenuItem1.setText(resourceMap.getString("jMenuItem1.text")); // NOI18N
            jMenuItem1.setName("jMenuItem1"); // NOI18N
            jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jMenuItem1ActionPerformed(evt);
                }
            });
            jMenu1.add(jMenuItem1);

            jMenuItem3.setText(resourceMap.getString("jMenuItem3.text")); // NOI18N
            jMenuItem3.setName("jMenuItem3"); // NOI18N
            jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jMenuItem3ActionPerformed(evt);
                }
            });
            jMenu1.add(jMenuItem3);

            fileMenu.add(jMenu1);

            jMenu2.setText(resourceMap.getString("jMenu2.text")); // NOI18N
            jMenu2.setName("jMenu2"); // NOI18N

            jMenuItem4.setText(resourceMap.getString("jMenuItem4.text")); // NOI18N
            jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jMenuItem4ActionPerformed(evt);
                }
            });
            jMenu2.add(jMenuItem4);

            jMenuItem5.setText(resourceMap.getString("jMenuItem5.text")); // NOI18N
            jMenuItem5.setName("jMenuItem5"); // NOI18N
            jMenuItem5.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jMenuItem5ActionPerformed(evt);
                }
            });
            jMenu2.add(jMenuItem5);

            fileMenu.add(jMenu2);

            javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(controlgasto.ControlGastoApp.class).getContext().getActionMap(ControlGastoView.class, this);
            exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
            exitMenuItem.setText(resourceMap.getString("exitMenuItem.text")); // NOI18N
            exitMenuItem.setName("exitMenuItem"); // NOI18N
            fileMenu.add(exitMenuItem);

            menuBar.add(fileMenu);

            jMenu3.setText(resourceMap.getString("jMenu3.text")); // NOI18N
            jMenu3.setName("jMenu3"); // NOI18N

            jMenuItem2.setText(resourceMap.getString("jMenuItem2.text")); // NOI18N
            jMenuItem2.setName("jMenuItem2"); // NOI18N
            jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jMenuItem2ActionPerformed(evt);
                }
            });
            jMenu3.add(jMenuItem2);

            menuBar.add(jMenu3);

            helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
            helpMenu.setName("helpMenu"); // NOI18N

            aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
            aboutMenuItem.setName("aboutMenuItem"); // NOI18N
            helpMenu.add(aboutMenuItem);

            menuBar.add(helpMenu);

            jScrollPane1.setName("jScrollPane1"); // NOI18N

            jTable1.setModel(new javax.swing.table.DefaultTableModel(
                new Object [][] {
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null}
                },
                new String [] {
                    "Title 1", "Title 2", "Title 3", "Title 4"
                }
            ));
            jTable1.setName("jTable1"); // NOI18N
            jScrollPane1.setViewportView(jTable1);

            setComponent(mainPanel);
            setMenuBar(menuBar);
        }// </editor-fold>//GEN-END:initComponents

    private void comboPersonasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboPersonasActionPerformed
        if(!fromDialogClosed){
            PersonaDAO persona = (PersonaDAO)comboPersonas.getSelectedItem();
            ReloadCombo.llenarTotales(opciones_calendario, persona.getId_persona(), txt_mayor_gasto,txt_descripcion, txt_total_mes, txt_total_anio);
            TableUtils.buscarGastosMesActual(tabla_informacion,opciones_calendario.getMonthChooser().getMonth()+1);
            tabs_graficos.removeAll();
            tabs_graficos.add(persona.getNombre(),new drawGraphsPanel().genLineGraph(persona.getId_persona(), opciones_calendario.getDate()));
            tabs_graficos.add("Todos",new drawGraphsPanel().genLineGraph(opciones_calendario.getDate()));
        }
        else{
            fromDialogClosed = false;
        }
    }//GEN-LAST:event_comboPersonasActionPerformed

    private void opciones_calendarioMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_opciones_calendarioMouseClicked
        /*PersonaDAO persona = (PersonaDAO)comboPersonas.getSelectedItem();
        ReloadCombo.llenarTotales(opciones_calendario, persona.getId_persona(), txt_mayor_gasto, txt_total_mes, txt_total_anio);
        tabs_graficos.removeAll();
        tabs_graficos.add("Mensual",new drawGraphsPanel().genLineGraph(persona.getId_persona(), opciones_calendario.getDate()));*/
    }//GEN-LAST:event_opciones_calendarioMouseClicked

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        JFrame mainFrame = ControlGastoApp.getApplication().getMainFrame();
        JDialog alta_gasto = new AltaGasto(mainFrame, true);
        alta_gasto.setLocationRelativeTo(null);
        alta_gasto.setVisible(true);

        alta_gasto.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosed(WindowEvent e){
                TableUtils.buscarGastosMesActual(tabla_informacion,opciones_calendario.getMonthChooser().getMonth()+1);
            }
        });
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void jMenuItem6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem6ActionPerformed
        
    }//GEN-LAST:event_jMenuItem6ActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        JFrame mainFrame = ControlGastoApp.getApplication().getMainFrame();
        JDialog alta_persona = new AltaPersona(mainFrame, true);
        alta_persona.setLocationRelativeTo(null);
        alta_persona.setVisible(true);

        alta_persona.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosed(WindowEvent e){
                fromDialogClosed = true;
                comboPersonas.removeAllItems();
                ReloadCombo.llenarComboPersonas(comboPersonas);
            }
        });
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        JFrame mainFrame = ControlGastoApp.getApplication().getMainFrame();
        JDialog compararPorMes = new CompararMes(mainFrame, true);
        compararPorMes.setLocationRelativeTo(null);
        compararPorMes.setVisible(true);
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        PersonaDAO persona = (PersonaDAO)comboPersonas.getSelectedItem();
        ReloadCombo.llenarTotales(opciones_calendario, persona.getId_persona(), txt_mayor_gasto,txt_descripcion, txt_total_mes, txt_total_anio);
        TableUtils.buscarGastosMesActual(tabla_informacion,opciones_calendario.getMonthChooser().getMonth()+1);
        tabs_graficos.removeAll();
        tabs_graficos.add(persona.getNombre(),new drawGraphsPanel().genLineGraph(persona.getId_persona(), opciones_calendario.getDate()));
        tabs_graficos.add("Todos",new drawGraphsPanel().genLineGraph(opciones_calendario.getDate()));
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
        JFrame mainFrame = ControlGastoApp.getApplication().getMainFrame();
        JDialog modificar_persona = new ModificarPersona(mainFrame, true);
        modificar_persona.setLocationRelativeTo(null);
        modificar_persona.setVisible(true);

        modificar_persona.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosed(WindowEvent e){
                fromDialogClosed = true;
                comboPersonas.removeAllItems();
                ReloadCombo.llenarComboPersonas(comboPersonas);
            }
        });
    }//GEN-LAST:event_jMenuItem4ActionPerformed

    private void jMenuItem5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem5ActionPerformed
        JFrame mainFrame = ControlGastoApp.getApplication().getMainFrame();
        JDialog modificar_gasto = new ModificarGasto(mainFrame, true);
        modificar_gasto.setLocationRelativeTo(null);
        modificar_gasto.setVisible(true);
    }//GEN-LAST:event_jMenuItem5ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox comboPersonas;
    private javax.swing.JButton jButton1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable jTable1;
    private javax.swing.JLabel label_mayor_gasto;
    private javax.swing.JLabel label_mayor_gasto1;
    private javax.swing.JLabel label_total_anio;
    private javax.swing.JLabel label_total_anio1;
    private javax.swing.JLabel label_total_mes;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private com.toedter.calendar.JCalendar opciones_calendario;
    private javax.swing.JPanel panel_informacion;
    private javax.swing.JPanel panel_opciones;
    private javax.swing.JTable tabla_informacion;
    private javax.swing.JTabbedPane tabs_graficos;
    private javax.swing.JTextField txt_descripcion;
    private javax.swing.JTextField txt_mayor_gasto;
    private javax.swing.JTextField txt_total_anio;
    private javax.swing.JTextField txt_total_mes;
    // End of variables declaration//GEN-END:variables

   
    private JDialog aboutBox;
    private JDialog selecciondb;
}
